<%= button_to 'Create New Message', :action => 'new'%><p>
	
<span id='message_count'><%= "You have "+pluralize(@messages.total_entries, "messages")%> in archive</span><br>
<% if @user.team_name!="" %>
Messages in <font color='red'>red</font> were sent to the team <%= @user.team_name%><br>
<% end %>
<%= link_to 'Show Inbox',:action=>'index'%> |
<%= link_to 'Audit Sent Messages', :action => 'out'%><p>
<p>
<% for message in @messages%>
	<%= "<div id='message_"+message.id.to_s+"'>" %>
	<%= "<font color='red'>" if message.recipient_id.to_s ==@user.team.to_s %>	
	<b><%= message.subject%></b>
	<%="</font>" if message.recipient_id.to_s==@user.team.to_s %>
	From : <%= message.sender.given_names if message.sender.given_names%> <%= message.sender.family_name if message.sender.family_name %>
	Date : <%=message.created_at.strftime("%H:%M %d/%m/%y") %>
	<br>
	<%= link_to "Regarding: "+ message.patient.full_name+"<br>",{:controller=>"record",:action=>"show",:wedgetail=>message.re} if message.re.to_s!="" %>
	<%= "<div id='message_content_"+message.id.to_s+"' style='display: none'>" %>

	<%= simple_format(message.content) %>
	</div>
	<%= link_to_remote "Show/Hide", :url => {:action => "toggle",:id=> message.id,} %> |  
	<%= link_to_remote 'Reply',
	 					:url => {:controller => 'messages',:action=> 'new_ajax',:id=> message.id},
						:update=>"message_reply_"+message.id.to_s,
						:complete=> visual_effect(:blind_down, "message_reply_"+message.id.to_s) -%> |

						

	<%= link_to_remote "Mark as Read", :url => {:action => "mark_as_read",:id=> message.id} if message.status==0%><br/>
	<%= "<div id='message_reply_"+message.id.to_s+"' >" %></div>
	
	


	<hr>
	</div>

<% end%>
<%= will_paginate @messages %>